package org.lanqiao.tjut.dao;

import java.util.List;

import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.lanqiao.tjut.bean.UsersBean;
import org.lanqiao.tjut.db.DBDriverFactory;

public class LoginDao {

	/**
	 * 用户登录验证
	 * 
	 * @param uBean
	 *            用户信息实体兑现
	 * @return 查询结果(boolean变量)
	 */
	public boolean isLogined(UsersBean uBean) {
		boolean isL = false;
		// sql语句
		String strSql = "SELECT * FROM PDUUSERS WHERE USERNAME=? AND USERPSW=?";
		// 进行数据库查询操作
		List<UsersBean> lst = DBDriverFactory.getDBDriverInstance().query(strSql,
				new BeanListHandler<UsersBean>(UsersBean.class),
				new Object[] { uBean.getUsername(), uBean.getUserpsw() });

		// 根据查询结果判定用户是否验证成功
		if (lst != null && lst.size() > 0) {
			isL = true;
		}
		return isL;
	}

	/**
	 * 用户登录验证
	 * 
	 * @param uBean
	 *            用户信息实体兑现
	 * @return 查询结果(list集合)
	 */
	public List<UsersBean> isLogined2(UsersBean uBean) {
		// sql语句
		String strSql = "SELECT * FROM PDUUSERS WHERE USERNAME=? AND USERPSW=?";
		// 进行数据库查询操作
		List<UsersBean> lst = DBDriverFactory.getDBDriverInstance().query(strSql,
				new BeanListHandler<UsersBean>(UsersBean.class),
				new Object[] { uBean.getUsername(), uBean.getUserpsw() });
		return lst;
	}
}
